<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<html>
<head>
	<title>预约客户管理</title>
	<meta name="decorator" content="default"/>
</head>
<body>
<div class="main-content">
    <tags:breadcrumb menuId="预约查询" />
    <div class="page-content">
        <form:form id="searchForm" modelAttribute="cchomeCustom" action="${ctx}/customer/cchomeCustom/" method="post" cssStyle="margin-bottom: 5px;" >
            <input id="pageNo" name="pageNo" type="hidden" value="${page.pageNo}"/>
            <input id="pageSize" name="pageSize" type="hidden" value="${page.pageSize}"/>
            <label>名称 ：</label><form:input path="name" htmlEscape="false" maxlength="50" class="input-medium"/>
            &nbsp;<input id="btnSubmit" class="btn btn-primary btn-sm" type="submit" value="查询"/>
        </form:form>
        <table id="contentTable" class="table table-striped table-bordered table-hover">
            <thead>
            <tr>
                <th>客户名称</th>
                <th>手机号码</th>
                <th>预约开始日期</th>
                <th>预约结束日期</th>
                <th>处理结果</th>
                <th>预约时间</th>
                <shiro:hasPermission name="customer:cchomeCustom:view">
                    <th>操作</th>
                </shiro:hasPermission></tr>
            </thead>
            <tbody>
            <c:forEach items="${page.list}" var="cchomeCustom">
                <tr>
                    <td><a href="${ctx}/customer/cchomeCustom/form?id=${cchomeCustom.id}">${cchomeCustom.name}</a></td>
                    <td>${cchomeCustom.mobile}</td>
                    <td>${cchomeCustom.appointBegDate}</td>
                    <td>${cchomeCustom.appointEndDate}</td>
                    <td>
                        <c:choose>
                            <c:when test="${cchomeCustom.isDeal eq '0'}">
                                <span class="label label-danger">未处理</span>
                            </c:when>
                            <c:when test="${cchomeCustom.isDeal eq '1'}">
                                <span class="label label-success">已处理</span>
                            </c:when>
                        </c:choose>
                    </td>
                    <td><fmt:formatDate value="${cchomeCustom.createTime}" pattern="yyyy-MM-dd HH:mm:ss"/> </td>
                    <shiro:hasPermission name="customer:cchomeCustom:view"><td>
                        <c:choose>
                            <c:when test="${cchomeCustom.isDeal eq '0'}">
                                <a href="javascript:;" onclick="deal(1,'${cchomeCustom.id}');">处理</a>
                            </c:when>
                            <c:when test="${cchomeCustom.isDeal eq '1'}">
                                <a href="javascript:;" onclick="deal(0,'${cchomeCustom.id}');">取消处理</a>
                            </c:when>
                        </c:choose>
                        <a href="javascript:;" onclick="deleteMsg('确认要删除该文本消息模板吗？','${ctx}/customer/cchomeCustom/delete?id=${cchomeCustom.id}',this);">删除</a>
                    </td></shiro:hasPermission>
                </tr>
            </c:forEach>
            </tbody>
        </table>
        <div class="pagination">${page}</div>
    </div>
</div>
<script type="text/javascript">
    $(document).ready(function() {

    });

    //删除
    function deleteMsg(msg,href,tr){
        layer.confirm(msg,function(index){
            layer.close(index);
            loading();
            $.post(href,function(data){
                if(data.success){
                    showNote("success", function () {
                        $(tr).parent().parent().remove();
                    }, data.msg, "center");
                }else {
                    showNote("error", function () {
                        return false;
                    }, data.msg);
                }
            });
        });
    }

    //处理预约客人
    function deal(type,id){
        var url = "${ctx}/customer/cchomeCustom/deal";
        var mess = "";
        if(type==1){
            mess = "确定处理该客户的预约申请?";
        }else {
            mess = "确定取消处理该客户的预约申请?";
        }
        layer.confirm(mess,{icon:3,title:"温馨提示"},function(index){
            layer.close(index);
            loading();
            $.post();
            $.post(url,{type:type,id:id},function(data){
                if(data.success){
                    showNote("success", function () {
                        window.location.href = "${ctx}/customer/cchomeCustom/list";
                    }, data.msg, "center");
                }else{
                    showNote("error", function () {return false;}, data.msg, "center");
                }
            });
        });
    }

    function page(n,s){
        $("#pageNo").val(n);
        $("#pageSize").val(s);
        $("#searchForm").submit();
        return false;
    }
</script>
</body>
</html>
